package model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import org.hibernate.annotations.Formula;

/**
 *
 * @author rodolpho
 */
@Entity
@Table(name = "ACAO_GRUPO")
@XmlRootElement
public class AcaoGrupo implements Serializable {

    private long agrCodigo;
    private String agrNome;
    private Boolean agrAtivo;
    /**
     * Formula
     */
    private String agrAtivoDesc;

    @Id
    @SequenceGenerator(name = "seqAcaoGrupo", sequenceName = "SEQ_ACAO_GRUPO")
    @Column(name = "AGR_CODIGO", unique = true, nullable = false, precision = 10, scale = 0)
    public long getAgrCodigo() {
        return agrCodigo;
    }

    public void setAgrCodigo(long agrCodigo) {
        this.agrCodigo = agrCodigo;
    }

    @Column(name = "AGR_NOME", length = 100)
    public String getAgrNome() {
        return agrNome;
    }

    public void setAgrNome(String agrNome) {
        this.agrNome = agrNome;
    }

    @Column(name = "AGR_ATIVO", length = 1)
    public Boolean getAgrAtivo() {
        return agrAtivo;
    }

    public void setAgrAtivo(Boolean agrAtivo) {
        this.agrAtivo = agrAtivo;
    }

    @Formula("(CASE WHEN AGR_ATIVO = 1 THEN 'Sim' ELSE 'Não' END)")
    public String getAgrAtivoDesc() {
        return agrAtivoDesc;
    }

    public void setAgrAtivoDesc(String agrAtivoDesc) {
        this.agrAtivoDesc = agrAtivoDesc;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (int) (this.agrCodigo ^ (this.agrCodigo >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final AcaoGrupo other = (AcaoGrupo) obj;
        if (this.agrCodigo != other.agrCodigo) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return agrNome;
    }
}
